package com.qf.service.Impl;

import com.qf.dao.CartDao;
import com.qf.dao.impl.CarDaoImpl;
import com.qf.pojo.CartItem;
import com.qf.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CartServiceImpl implements CartService {

    @Autowired
    CartDao cartDao;




    @Override
    public void addCart(String goodId, long uid, int num) {
        Long count = cartDao.findCountByUidAndPid(goodId, uid);
        if (count > 0){
            cartDao.updateNum(goodId, uid, num);
        }else {
            cartDao.addCart(goodId, uid, num);
        }
    }

    @Override
    public List<CartItem> findCartByUid(long uid) {
        return cartDao.findCartByUid(uid);
    }
}
